<?php
namespace app\wechat\controller;



class RCertification extends Common
{
    // 申请页面
    public function index()
    {
        /*PJ非微信本地测试方法*/
        if( @intval($_COOKIE["PJ"]) ){session('member_id',@intval($_COOKIE["PJ"]));}


        $member = db('member')->where('id', session('member_id') )->find();
        $repair['member'] = $member;
        $this->assign('member', $member);

        $param['member_id'] = session('member_id');
        $param['terrace'] = 'weixin';
        $repair = call_interface('repair_store_index',$param);
        if($repair["code"]!=200) {
            $repair["data"] = [];
        }
        if (isset($repair["data"]['audit_status']) && $repair["data"]['audit_status'] == 4) {
            $this->redirect(url('r_member/index'));
        }
        $this->assign('repair', $repair["data"]);

        return view();
    }

    // 咨询页面
//    public function consult()
//    {
//        return view();
//    }

    // post申请开店
    public function certification() {
        if (request()->isAjax()) {

            $param = [
                'member_id' => session('member_id'),
                'repair_name' => input('param.s_repair_name'),

                'province' => input('param.s_province'),
                'city' => input('param.s_city'),
                'area' => input('param.s_area'),
                'street' => input('param.s_street'),
                'address' => input('param.s_address'),

                'proposer' => input('param.s_proposer'),
                'card_no' => input('param.s_card_no'),
                'id_card_in_hand' => input('param.s_id_card_in_hand'),
                'id_card_front' => input('param.s_id_card_front'),
                'id_card_verso' => input('param.s_id_card_verso'),

                'business_license_name' => input('param.s_business_license_name'),
                'business_license_num' => input('param.s_business_license_num'),
                'business_license' => input('param.s_business_license'),

                'logo' => input('param.s_logo'),
                'cover' => input('param.s_cover'),

                'environment_img1' => input('param.s_environment_img1', ''),
                'environment_img2' => input('param.s_environment_img2', ''),
                'environment_img3' => input('param.s_environment_img3', ''),
                'environment_img4' => input('param.s_environment_img4', ''),
                'environment_img5' => input('param.s_environment_img5', ''),
                'environment_img6' => input('param.s_environment_img6', ''),
                'environment_img7' => input('param.s_environment_img7', ''),
                'environment_img8' => input('param.s_environment_img8', ''),

                'phone' => input('param.s_phone'),

                'lat' => input('param.s_lat'),
                'lon' => input('param.s_lon')
            ];

            $data = call_interface('repair_create',$param);
            return json($data);
        } else {
            return view('public/error');
        }
    }

    // 申请状态查询
    public function audit_status()
    {

        $status = input('param.status');
        $this->assign('status', $status);
        $member_id = session('member_id');
        $repair = db('repair')->where('member_id', $member_id)->find();
        $this->assign('repair', $repair);

        return view();
    }


}
